home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / LIB / GETUINT.C < prev    next >
C/C++ Source or Header  |  1995-11-26  |  711b  |  41 lines

  1. /* ============ */
  2. /* GetUint.c    */
  3. /* ============ */
  4. #include <stdio.h>
  5.  
  6. #define    FLUSH_LINE(u)            \
  7.     {                    \
  8.     int    x;            \
  9.     do                \
  10.     {                \
  11.         x = getc(u);        \
  12.     }                \
  13.     while (x != EOF && x != '\n');    \
  14.     }
  15. typedef    unsigned int    UINT;
  16. /* ==================================================== */
  17. /* GetUint - prompts operator with s to get UINT i    */
  18. /* ==================================================== */
  19. # if defined(__STDC__) || defined(__PROTO__)
  20. void
  21. GetUint(char *s, UINT *i)
  22. # else
  23. void
  24. GetUint(s, i)
  25. char    *s;
  26. UINT    *i;
  27. # endif
  28. {
  29.     {
  30.     unsigned long Trial;
  31.  
  32.     fprintf(stderr, "%s", s);
  33.  
  34.     scanf("%lu", &Trial);
  35.  
  36.     *i = (UINT)Trial;
  37.     }
  38.  
  39.     FLUSH_LINE(stdin);
  40. }
  41.